package com.itheima.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.bean.DishFlavor;
import com.itheima.dao.DishFlavorDao;
import com.itheima.service.DishFlavorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class DishFlavorServiceImpl implements DishFlavorService {

    @Autowired
    private DishFlavorDao dishFlavorDao;

    /**
     * 添加菜品风味
     * @param dishFlavor
     * @return
     */
    @Override
    public int insert(DishFlavor dishFlavor) {
        int insert = dishFlavorDao.insert(dishFlavor);
        return insert;
    }

    @Override
    public List<DishFlavor> selectByDishID(long id) {
        LambdaQueryWrapper<DishFlavor> qw = new LambdaQueryWrapper<>();
        qw.eq(DishFlavor::getDishId,id);
        List<DishFlavor> dishFlavors = dishFlavorDao.selectList(qw);
        return dishFlavors;
    }

    @Override
    public int delete(long id) {
        LambdaQueryWrapper<DishFlavor> qw = new LambdaQueryWrapper<>();
        qw.eq(DishFlavor::getDishId,id);
       return dishFlavorDao.delete(qw);


    }


}
